﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MauiControl.Services
{
    public interface INavigationService
    {
        Task NavigateToAsync<T>() where T : Page;
        Task NavigateToAsync<T>(object parameter) where T : Page;
    }

    public class NavigationService : INavigationService
    {
        public async Task NavigateToAsync<T>() where T : Page
        {
            // 使用绝对路径
            await Shell.Current.GoToAsync($"///{typeof(T).Name}");
        }

        public async Task NavigateToAsync<T>(object parameter) where T : Page
        {
            // 使用绝对路径
            await Shell.Current.GoToAsync($"///{typeof(T).Name}", new Dictionary<string, object>
        {
            { "ConnectedDevice", parameter }
        });
        }
    }
}
